import { createRouter, createWebHashHistory } from 'vue-router';
import routers from './routers';
import type { RouteRecordRaw } from 'vue-router';

const routes: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'login',
    meta: { title: '登录' },
    component: () => import('@/views/login/login.vue')
  },
  {
    path: '/',
    component: () => import('@/layout/layout.vue'),
    redirect: { name: routers[0].name },
    children: routers as RouteRecordRaw[]
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes
});

// 菜单
const menus = routers.filter(i => i.meta.isMenu);

export { menus };
export default router;
